package com.gaogzhen.cas;

/**
 * synchronized加锁实现
 */
public class AccountSynchronized implements Account{
    private Integer balance;

    public AccountSynchronized(Integer balance) {
        this.balance = balance;
    }

    @Override
    public synchronized Integer getBalance() {
        return this.balance;
    }

    @Override
    public synchronized void withdraw(Integer amount) {
        this.balance -= amount;
    }
}
